#ifndef THINK_THINK_CONSOLE_COMMAND_CLEAR_H
#define THINK_THINK_CONSOLE_COMMAND_CLEAR_H

static char* think_console_command_clear =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: liu21st <liu21st@gmail.com>\n"
	"// +----------------------------------------------------------------------\n"
	"namespace think\\console\\command;\n"
	"\n"
	"use think\\Cache;\n"
	"use think\\console\\Command;\n"
	"use think\\console\\Input;\n"
	"use think\\console\\input\\Argument;\n"
	"use think\\console\\input\\Option;\n"
	"use think\\console\\Output;\n"
	"\n"
	"class Clear extends Command\n"
	"{\n"
	"    protected function configure()\n"
	"    {\n"
	"        // 指令配置\n"
	"        $this\n"
	"            ->setName(\'clear\')\n"
	"            ->addArgument(\'type\', Argument::OPTIONAL, \'type to clear\', null)\n"
	"            ->addOption(\'path\', \'d\', Option::VALUE_OPTIONAL, \'path to clear\', null)\n"
	"            ->setDescription(\'Clear runtime file\');\n"
	"    }\n"
	"\n"
	"    protected function execute(Input $input, Output $output)\n"
	"    {\n"
	"        $path = $input->getOption(\'path\') ?: RUNTIME_PATH;\n"
	"\n"
	"        $type = $input->getArgument(\'type\');\n"
	"\n"
	"        if ($type == \'route\') {\n"
	"            Cache::clear(\'route_check\');\n"
	"        } else {\n"
	"            if (is_dir($path)) {\n"
	"                $this->clearPath($path);\n"
	"            }\n"
	"        }\n"
	"\n"
	"        $output->writeln(\"<info>Clear Successed</info>\");\n"
	"    }\n"
	"\n"
	"    protected function clearPath($path)\n"
	"    {\n"
	"        $path  = realpath($path) . DS;\n"
	"        $files = scandir($path);\n"
	"        if ($files) {\n"
	"            foreach ($files as $file) {\n"
	"                if (\'.\' != $file && \'..\' != $file && is_dir($path . $file)) {\n"
	"                    $this->clearPath($path . $file);\n"
	"                } elseif (\'.gitignore\' != $file && is_file($path . $file)) {\n"
	"                    unlink($path . $file);\n"
	"                }\n"
	"            }\n"
	"        }\n"
	"    }\n"
	"}\n"
	"\n"
;
#endif